package com.yx.learn.domain;

import java.sql.Timestamp;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * Role entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "trole", catalog = "yx_01")
public class Role implements java.io.Serializable {

	// Fields

	private Integer id;
	private Company company;
	private String roleNo;
	private String roleName;
	private Integer pid;
	private Timestamp createTime;
	private String memo;
	private Set<Userrole> userroles = new HashSet<Userrole>(0);
	private Set<Roleauthority> roleauthorities = new HashSet<Roleauthority>(0);

	// Constructors

	/** default constructor */
	public Role() {
	}

	/** minimal constructor */
	public Role(Integer id, Company company, String roleNo, String roleName,
			Integer pid, Timestamp createTime) {
		this.id = id;
		this.company = company;
		this.roleNo = roleNo;
		this.roleName = roleName;
		this.pid = pid;
		this.createTime = createTime;
	}

	/** full constructor */
	public Role(Integer id, Company company, String roleNo, String roleName,
			Integer pid, Timestamp createTime, String memo,
			Set<Userrole> userroles, Set<Roleauthority> roleauthorities) {
		this.id = id;
		this.company = company;
		this.roleNo = roleNo;
		this.roleName = roleName;
		this.pid = pid;
		this.createTime = createTime;
		this.memo = memo;
		this.userroles = userroles;
		this.roleauthorities = roleauthorities;
	}

	// Property accessors
	@Id
	@Column(name = "id", unique = true, nullable = false)
	@GeneratedValue
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "companyID", nullable = false)
	public Company getCompany() {
		return this.company;
	}

	public void setCompany(Company company) {
		this.company = company;
	}

	@Column(name = "roleNo", nullable = false, length = 20)
	public String getRoleNo() {
		return this.roleNo;
	}

	public void setRoleNo(String roleNo) {
		this.roleNo = roleNo;
	}

	@Column(name = "roleName", nullable = false, length = 64)
	public String getRoleName() {
		return this.roleName;
	}

	public void setRoleName(String roleName) {
		this.roleName = roleName;
	}

	@Column(name = "pid", nullable = false)
	public Integer getPid() {
		return this.pid;
	}

	public void setPid(Integer pid) {
		this.pid = pid;
	}

	@Column(name = "createTime", nullable = false, length = 0)
	public Timestamp getCreateTime() {
		return this.createTime;
	}

	public void setCreateTime(Timestamp createTime) {
		this.createTime = createTime;
	}

	@Column(name = "memo", length = 200)
	public String getMemo() {
		return this.memo;
	}

	public void setMemo(String memo) {
		this.memo = memo;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "role")
	public Set<Userrole> getUserroles() {
		return this.userroles;
	}

	public void setUserroles(Set<Userrole> userroles) {
		this.userroles = userroles;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "role")
	public Set<Roleauthority> getRoleauthorities() {
		return this.roleauthorities;
	}

	public void setRoleauthorities(Set<Roleauthority> roleauthorities) {
		this.roleauthorities = roleauthorities;
	}

}